/**
 */
package ms.unicorn.dsl.unicornDSL.impl;

import java.util.Collection;

import ms.unicorn.dsl.unicornDSL.UnicornDSLPackage;
import ms.unicorn.dsl.unicornDSL.XConstructionExpression;
import ms.unicorn.dsl.unicornDSL.XExpression;
import ms.unicorn.dsl.unicornDSL.XJavaTypeImport;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>XConstruction Expression</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ms.unicorn.dsl.unicornDSL.impl.XConstructionExpressionImpl#getType <em>Type</em>}</li>
 *   <li>{@link ms.unicorn.dsl.unicornDSL.impl.XConstructionExpressionImpl#getArguments <em>Arguments</em>}</li>
 *   <li>{@link ms.unicorn.dsl.unicornDSL.impl.XConstructionExpressionImpl#getInitExps <em>Init Exps</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class XConstructionExpressionImpl extends XExpressionImpl implements XConstructionExpression
{
  /**
   * The cached value of the '{@link #getType() <em>Type</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getType()
   * @generated
   * @ordered
   */
  protected XJavaTypeImport type;

  /**
   * The cached value of the '{@link #getArguments() <em>Arguments</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getArguments()
   * @generated
   * @ordered
   */
  protected EList<XExpression> arguments;

  /**
   * The cached value of the '{@link #getInitExps() <em>Init Exps</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getInitExps()
   * @generated
   * @ordered
   */
  protected EList<XExpression> initExps;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected XConstructionExpressionImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return UnicornDSLPackage.Literals.XCONSTRUCTION_EXPRESSION;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public XJavaTypeImport getType()
  {
    if (type != null && type.eIsProxy())
    {
      InternalEObject oldType = (InternalEObject)type;
      type = (XJavaTypeImport)eResolveProxy(oldType);
      if (type != oldType)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, UnicornDSLPackage.XCONSTRUCTION_EXPRESSION__TYPE, oldType, type));
      }
    }
    return type;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public XJavaTypeImport basicGetType()
  {
    return type;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setType(XJavaTypeImport newType)
  {
    XJavaTypeImport oldType = type;
    type = newType;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, UnicornDSLPackage.XCONSTRUCTION_EXPRESSION__TYPE, oldType, type));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<XExpression> getArguments()
  {
    if (arguments == null)
    {
      arguments = new EObjectContainmentEList<XExpression>(XExpression.class, this, UnicornDSLPackage.XCONSTRUCTION_EXPRESSION__ARGUMENTS);
    }
    return arguments;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<XExpression> getInitExps()
  {
    if (initExps == null)
    {
      initExps = new EObjectContainmentEList<XExpression>(XExpression.class, this, UnicornDSLPackage.XCONSTRUCTION_EXPRESSION__INIT_EXPS);
    }
    return initExps;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case UnicornDSLPackage.XCONSTRUCTION_EXPRESSION__ARGUMENTS:
        return ((InternalEList<?>)getArguments()).basicRemove(otherEnd, msgs);
      case UnicornDSLPackage.XCONSTRUCTION_EXPRESSION__INIT_EXPS:
        return ((InternalEList<?>)getInitExps()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case UnicornDSLPackage.XCONSTRUCTION_EXPRESSION__TYPE:
        if (resolve) return getType();
        return basicGetType();
      case UnicornDSLPackage.XCONSTRUCTION_EXPRESSION__ARGUMENTS:
        return getArguments();
      case UnicornDSLPackage.XCONSTRUCTION_EXPRESSION__INIT_EXPS:
        return getInitExps();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case UnicornDSLPackage.XCONSTRUCTION_EXPRESSION__TYPE:
        setType((XJavaTypeImport)newValue);
        return;
      case UnicornDSLPackage.XCONSTRUCTION_EXPRESSION__ARGUMENTS:
        getArguments().clear();
        getArguments().addAll((Collection<? extends XExpression>)newValue);
        return;
      case UnicornDSLPackage.XCONSTRUCTION_EXPRESSION__INIT_EXPS:
        getInitExps().clear();
        getInitExps().addAll((Collection<? extends XExpression>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case UnicornDSLPackage.XCONSTRUCTION_EXPRESSION__TYPE:
        setType((XJavaTypeImport)null);
        return;
      case UnicornDSLPackage.XCONSTRUCTION_EXPRESSION__ARGUMENTS:
        getArguments().clear();
        return;
      case UnicornDSLPackage.XCONSTRUCTION_EXPRESSION__INIT_EXPS:
        getInitExps().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case UnicornDSLPackage.XCONSTRUCTION_EXPRESSION__TYPE:
        return type != null;
      case UnicornDSLPackage.XCONSTRUCTION_EXPRESSION__ARGUMENTS:
        return arguments != null && !arguments.isEmpty();
      case UnicornDSLPackage.XCONSTRUCTION_EXPRESSION__INIT_EXPS:
        return initExps != null && !initExps.isEmpty();
    }
    return super.eIsSet(featureID);
  }

} //XConstructionExpressionImpl
